package top.zyx.rpc.registry.ZK;

import org.apache.curator.framework.CuratorFramework;
import top.zyx.rpc.registry.ServiceRegistry;
import top.zyx.rpc.util.CuratorUtils;

import java.net.InetSocketAddress;

public class ZKServiceRegistry implements ServiceRegistry {

    @Override
    public void register(String serviceName, InetSocketAddress inetSocketAddress) {
        String servicePath = CuratorUtils.ZK_REGISTER_ROOT_PATH + "/" + serviceName + inetSocketAddress.toString();
        CuratorFramework zkClient = CuratorUtils.getZkClient();
        CuratorUtils.createPersistentNode(zkClient, servicePath);
    }
}
